import React, {Component} from 'react';
import {base, high} from 'nc-lightapp-front';
import getComponent from "../../functions/getComponent";

class BatchEditComp extends Component {
    constructor(props) {
        super(props);
        this.state = {};
        this.config = [
            {
                key: 'endflag',
                name: this.props.json['hi6007-000103'],/* 国际化处理： 结束标志*/
                type: 'checkbox'
            },
            {
                key: 'enddate',
                name: this.props.json['hi6007-000104'],/* 国际化处理： 结束日期*/
                type: 'datePickerNoTimeZone'
            },
            {
                key: 'pk_job_type',
                name: this.props.json['hi6007-000105'],/* 国际化处理： 任职类型*/
                type: 'refer',
                refConfig: {
                    refType: 'grid',
                    refCode: 'uapbd.refer.userdef.DefdocGridRef',
                    queryGridUrl: '/nccloud/uapbd/userdef/DefdocGridRef.do',
                    queryCondition: {
                        "pk_defdoclist": "1001Z71000000000FLQ9",
                        "DataPowerOperationCode": null,
                        "isDataPowerEnable": false,
                        "isShowUnit": false
                    }
                }
            },
            {
                key: 'memo',
                name: this.props.json['hi6007-000106'],/* 国际化处理： 备注*/
                type: 'textarea'
            }
        ];
        this.fieldKeys = this.config.map(item => item.key);
    }

    getInfo() {
        let info = {};
        this.config.forEach(item => {
            if (this.state[item.key + '_flag']) {
                if (item.type === 'refer') {
                    if (this.state[item.key]) {
                        info[item.key] = this.state[item.key].refpk
                    }
                } else {
                    const value = this.state[item.key];
                    info[item.key] = value === undefined ?
                        (item.type === 'switch' || item.type === 'checkbox') ? false : '' : value
                }
            }
        });
        return info;
    }

    render() {
        return (
            <div>
                {getComponent.call(this)}
            </div>
        );
    }
}

export default BatchEditComp;
